/**
 *
 * User: rendong
 * Date: 12-9-3
 * Time: 下午9:57
 * $Id: GDisplayObject.js 12 2012-09-10 16:47:05Z rendong237@gmail.com $
 */

function GDisplayObject(){}
GDisplayObject.extend(new GEventDispatcher());

GDisplayObject.prototype.name = "";
GDisplayObject.prototype.parent = null;
GDisplayObject.prototype.stage = null;


GDisplayObject.prototype.alpha = 1;
GDisplayObject.prototype.visible = true;

// TODO:元素宽高处理

GDisplayObject.prototype._width = 0;
Object.defineProperty(GDisplayObject.prototype, 'width',{
    set : function (val) {
        this._width = val;
        this.boundRect.width = val;
        if (this.oldBoundRect.width != val)
            this.isReDraw = true;
    },
    get : function () {return this._width; },
    enumerable : true
});

GDisplayObject.prototype._height = 0;
Object.defineProperty(GDisplayObject.prototype, 'height',{
    set : function (val) {
        this._height = val;
        this.boundRect.height = val;
        if (this.oldBoundRect.height != val)
            this.isReDraw = true;
    },
    get : function () {return this._height; },
    enumerable : true
});

// TODO:元素位置变化处理
GDisplayObject.prototype._x = 0;
Object.defineProperty(GDisplayObject.prototype, 'x',{
    set : function (val) {
        this._x = val;
        this.boundRect.x = val;
        if (this.oldBoundRect.x != val)
            this.isReDraw = true;
    },
    get : function () { return this._x; },
    enumerable : true
});


GDisplayObject.prototype._y = 0;
Object.defineProperty(GDisplayObject.prototype, 'y',{
    set : function (val) {
        this._y = val;
        this.boundRect.y = val;
        if (this.oldBoundRect.y != val)
            this.isReDraw = true;
    },
    get : function () { return this._y; },
    enumerable : true
});

GDisplayObject.prototype.mask = null;

GDisplayObject.prototype.mouseEnabled = true;

/**
 * 显示区域
 * @type {GRect}
 */
GDisplayObject.prototype.boundRect = new GRect(0,0,0,0);

/**
 * 用来计算脏矩形使用
 * @type {GRect}
 */
GDisplayObject.prototype.oldBoundRect = new GRect(0,0,0,0);

/**
 * 是否需要重绘，脏矩形计算是否开启
 * @type {GRect}
 */
GDisplayObject.prototype.isReDraw = false;

/**
 *
 * @param point
 */
GDisplayObject.prototype.globalToLocal = function (point)
{

}

GDisplayObject.prototype.localToGlobal = function (point)
{

}

GDisplayObject.prototype.hitTestObject=function(dispobj)
{

}

GDisplayObject.prototype.render = function(dirtyRect)
{
    // empty
}


GDisplayObject.prototype.getBounds = function()
{

}